/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.cardarus.operatingsystem.domain;

import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;

/**
 * This class represents a row in a sales transaction.
 * Includes the item, the unit price, the quantity, the total price of the row.
 *
 * @author Javier Snaider
 */
@Entity
public class SalesTransactionRow implements Serializable {
    /**
     * The unique id of this SalesTransactionRow
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private int rowId;
    /**
     * the position of the row in the sales transaction.
     */
    private int rowNumber;
    /**
     * the SalesTransaction parent of this row.
     */
    @ManyToOne
    private SalesTransaction record;
    /**
     * The item of this row.
     */
    @ManyToOne
    private Item item;
    /**
     * The number of items that are included in this row.
     */
    private int quantity;
    /**
     * The price per unit of item.
     */
    private double unitPrice;
    /**
     * The total price of the row. It is equal to unitPrice * quantity.
     */
    private double price;

    /**
     * A SalesTransactionRow constructor that sets several attributes.
     *
     * @param rowId the row id to set.
     * @param rowNumber the number of the row to set.
     * @param item the Item of this row.
     * @param quantity the number of items of this row.
     * @param unitPrice the price per unit of item.
     * @param price the total price of the row.
     */
    public SalesTransactionRow(int rowId, int rowNumber, Item item, int quantity, double unitPrice, double price) {
        this.rowId = rowId;
        this.rowNumber = rowNumber;
        this.item = item;
        this.quantity = quantity;
        this.unitPrice = unitPrice;
        this.price = price;
    }
    /**
     * Default constructor.
     */
    public SalesTransactionRow() {
    }

    
    /**
     * @return the rowNumber
     */
    public int getRowNumber() {
        return rowNumber;
    }

    /**
     * @param rowNumber the rowNumber to set
     */
    public void setRowNumber(int rowNumber) {
        this.rowNumber = rowNumber;
    }

    /**
     * @return the record
     */
    public SalesTransaction getRecord() {
        return record;
    }

    /**
     * @param record the record to set
     */
    public void setRecord(SalesTransaction record) {
        this.record = record;
    }

    /**
     * @return the item
     */
    public Item getItem() {
        return item;
    }

    /**
     * @param item the item to set
     */
    public void setItem(Item item) {
        this.item = item;
    }

    /**
     * @return the quantity
     */
    public int getQuantity() {
        return quantity;
    }

    /**
     * @param quantity the quantity to set
     */
    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    /**
     * @return the unitPrice
     */
    public double getUnitPrice() {
        return unitPrice;
    }

    /**
     * @param unitPrice the unitPrice to set
     */
    public void setUnitPrice(double unitPrice) {
        this.unitPrice = unitPrice;
    }

    /**
     * @return the price
     */
    public double getPrice() {
        return price;
    }

    /**
     * @param price the price to set
     */
    public void setPrice(double price) {
        this.price = price;
    }

    /**
     *
     * @return the row id
     */
    public int getRowId() {
        return rowId;
    }

    /**
     * set the rowId
     * @param rowId
     */
    public void setRowId(int rowId) {
        this.rowId = rowId;
    }
}
